<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         function deepCopy(target){
            if(typeof target !== 'object'){
                return target
            }
            var result = Array.isArray(target) ? [] :{}
            if(Array.isArray(target)){
                for(var i = 0 ; i < target.length ; i++){
                    //多层用递归
                    result.push=deepCopy((target[i]))
                }
            } else{
                for(var k in target){
                    result[k] = deepCopy(target[k])
                }
                
            }
            return result
}
var obj = {name : 'lisi'}
var obj2 =deepCopy(obj)
console.log(obj2)
var hobby = ['踢毽子']
var hobby2 = deepCopy(hobby)
console.log(hobby2)
    </script>
   
</body>
</html>